package util;

import javax.swing.*;
import java.awt.*;

public class FrameUtil {

    /**
     * 窗口居中
     */
    public static void setFrameCenter(JFrame jf){
        //居中
        //获取窗口大小
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Dimension screen=toolkit.getScreenSize();
        //显示器宽度和高度
        int x = screen.width - jf.getWidth()>>1;
        int y = (screen.height - jf.getHeight()>>1) - 32;
        jf.setLocation(x,y);
    }
}
